import {Component, EventEmitter,ViewChild, Input, OnInit, Output} from '@angular/core';
import {Router} from '@angular/router';
import {HttpClient} from '@angular/common/http';
import { InitService } from '../../public/serve/init/init.service';
import { appThemeTagUrl } from './theme-tag.url';
import { themeTag } from './theme-tag.data';
import { RemoveTableService } from '../../public/serve/remove-table/remove-table.service';
import { Service } from '../../server/server';
import { HintsService } from '../../public/serve/hints/hints.service';
import { CudTableService } from '../../public/serve/cud-table/cud-table.service';
import {MessageService} from 'primeng/api';
import { ThemeTagTableComponent } from './theme-tag-table/theme-tag-table.component';
declare var $:any;

@Component({
  selector: 'app-theme-tag',
  templateUrl: './theme-tag.component.html',
  styleUrls: ['./theme-tag.component.css']
})
export class ThemeTagComponent implements OnInit {

  @ViewChild("table") table : ThemeTagTableComponent;

  @Input() status: any  = '';
  @Input() searchData: any;
  right: any = {
    "systemThemeTag": {},
  };

  constructor( 
    public initService: InitService,
    public removeTableService: RemoveTableService,
    public request: CudTableService,
    public server: Service,
    private hintsService: HintsService,
    private messageService:MessageService
  ){
    this.right = $.extend(this.right, server.getRight());
  }

  isActive = this.server.isActive;
  ngOnInit() {
    this.server.eventEmit.subscribe((value: any)=>{
      this.isActive = value;
    });
  }

 /**
   * 分页
   * @param pagination 
   */ 
  _pagination(pagination: Array<any>) {
    themeTag.pagination.pageNumber = pagination[0].pageNumber;
    themeTag.pagination.pageSize   = pagination[0].pageSize;
    themeTag.pagination.naturalNum = (themeTag.pagination.pageNumber - 1) * themeTag.pagination.pageSize;
    this.table.getThemeWordsLabelList();
  }

  //搜索
  search() {
    themeTag.retrieval.queryCriteria = this.searchData;
    this.table.getThemeWordsLabelList();
  }
  //响应搜索
  changesearch() {
      this.search();
  }

}
